<template>
	<view class="main">
<!-- 		<view class="h2">
			忘记密码
		</view> -->
		<view class="list">
			<view class="border a">
				<view class="left">
					手机号
				</view>
				<view class="right">
					<input v-model="mobile" type="text" value="" placeholder="请输入手机号" />
				</view>
			</view>
			<view class="" style="background-color: #f6f6f6; height: 4rpx;">
				
			</view>
			<view class="border a">
				<view class="left">
					验证码
				</view>
				<view class="right">
					<input v-model="code" type="text" value="" placeholder="请输入验证码" />
					<view @tap="getCode" class="codeBtn" v-if="!codeShow">
						获取验证码
					</view>
					<view class="codeBtn" v-else>
						<u-count-down :time="60 * 1000" format="ss" @finish="finish"></u-count-down>
						获取验证码
					</view>
				</view>
			</view>
			<view class="" style="background-color: #f6f6f6; height: 4rpx;">
				
			</view>
			<view class="border a">
				<view class="left">
					新密码
				</view>
				<view class="right">
					<input v-model="newpassword" type="password" value="" placeholder="请输入新密码" />
				</view>
			</view>
			<view class="" style="background-color: #f6f6f6; height: 4rpx;">
				
			</view>
			<view class="btn" @tap="confirm">
				确认修改
			</view>
		</view>
		
	</view>
</template>

<script>
	import {
		send,
		resetpwd
	} from '@/api/index.js'
	export default{
		data(){
			return{
				info:{},
				mobile:'',
				code:'',
				codeShow:false,
				newpassword:''
			}
		},
		onLoad() {
		},
		methods: {
			finish() {
				this.codeShow = true
			},
			async getCode() {
				if(this.mobile.length == 0){
					uni.showToast({
						title:'请输入手机号',
						icon:"none"
					})
					return
				}
				let res = await send({
					mobile: this.mobile,
					event: 'resetpwd'
				})
				if(res.code == 1){
					uni.showToast({
						title:'发送成功',
						icon:"none"
					})
				}else{
					uni.showToast({
						title:res.msg,
						icon:"none"
					})
				}
				this.codeShow = true
			},
			async confirm(){
				let res = await resetpwd({
					mobile:this.mobile,
					newpassword:this.newpassword,
					captcha:this.code
				})
				if(res.code == 1){
					uni.showToast({
						title:'修改成功',
						icon:"none"
					})
					setTimeout(() => {
						uni.navigateBack()
					},1000)
				}
				else{
					uni.showToast({
						title:res.msg,
						icon:"none"
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main{
		height: calc(100vh - 80rpx);
		background-color: #f6f6f6;
		padding: 30rpx 30rpx;
		box-sizing: border-box;
		color: #3c3c3c;
		.h2{
			font-size: 80rpx;
			font-weight: 700;
			color: #3c3c3c;
			margin-bottom: 40rpx;
		}
		.list{
			background-color: #fff;
			height:calc(100vh - 150rpx) ;
			padding: 20rpx;
			.border{
				// padding-bottom: 30rpx;
				box-sizing: border-box;
				border-bottom: 2rpx solid #fff;
				margin: 30rpx 0;
			}
			.a{
				display: flex;
				align-items: center;
				.left{
					width: 25%;
					color: #3c3c3c;
				}
				.right{
					flex: 1;
					color: #3c3c3c;
					display: flex;
					align-items: center;
					input{
						flex: 1;
					}
				}
				.codeBtn {
					padding: 10rpx 14rpx;
					background-color: #eaeaea;
					color: #201dd8;
					font-size: 24rpx;
					border-radius: 8rpx;
					margin-left: 6rpx;
					display: flex;
					align-items: center;
				    text-indent: 4rpx;
					::v-deep.u-count-down__text {
						color: #201dd8;
						font-size: 24rpx;
						line-height: 0;
					}
				}
			}
			.b{
				display: flex;
				align-items: center;
				.left{
					width: 25%;
					font-size: 24rpx;
				}
				.right{
					width: 75%;
					font-size: 24rpx;
					display: flex;
					align-items: center;
					input{
						flex: 1;
					}
					.btn{
						padding: 16rpx 20rpx;
						font-size: 24rpx;
						background-color: #ea504f;
						border-radius: 200rpx;
					}
				}
			}
			.c{
				.left{
					font-size: 28rpx;
					margin-bottom: 40rpx;
				}
				.idList{
					.idItem{
						padding: 16rpx 26rpx;
						border: 2rpx solid #fff;
						border-radius: 14rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						text{
							color: #3c3c3c;
							font-size: 24rpx;
						}
						.radio{
							display: flex;
							align-items: center;
							image{
								width: 34rpx;
								height: 34rpx;
							}
						}
					}
				}
			}
		}
		.btn{
			margin-top: 120rpx;
			width: 100%;
			padding: 30rpx;
			text-align: center;
			color: #3c3c3c;
			background-color: #ff6347;
			border-radius: 10rpx;
		}
	}
</style>